//
//  DiscoverViewController.m
//  project_delicious
//
//  Created by 章历杰 on 15/3/21.
//  Copyright (c) 2015年 lanou3g.com 蓝鸥科技. All rights reserved.
//

#import "DiscoverViewController.h"
#import "UIImageView+AFNetworking.h"
#import "CookStyleViewController.h"
#import "TheCuetomCell.h"
#import "SearchViewController.h"



@interface DiscoverViewController ()<UITableViewDataSource, UITableViewDelegate, UIScrollViewDelegate, CLLocationManagerDelegate>
@property (nonatomic, retain) NSMutableArray *arr;
@property (nonatomic, retain) NSMutableArray *arr1;
@property (nonatomic, retain) UITableView *tableView;
@property (nonatomic, retain) UIImageView *theImageView;
@end

@implementation DiscoverViewController

- (void)dealloc
{
    [_theImageView release];
    [_tableView release];
    [_arr release];
    [_arr1 release];
    
    [super dealloc];
}


- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.navigationController.navigationBarHidden = YES;
    self.navigationController.navigationBar.translucent = NO;

    
    self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"IMG_1345.JPG"]];
    UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:self.view.bounds];
    scrollView.delegate = self;
    scrollView.backgroundColor = [UIColor clearColor];
    [self.view addSubview:scrollView];
    [scrollView release];
    
    
    self.tableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain];
    _tableView.delegate = self;
    _tableView.dataSource = self;
    _tableView.scrollEnabled = NO;
    _tableView.backgroundColor = [UIColor clearColor];
    _tableView.separatorColor = [UIColor clearColor];
    [scrollView addSubview:_tableView];
    [_tableView release];
    
    [_tableView registerClass:[TheCuetomCell class] forCellReuseIdentifier:@"guo"];
    self.arr = [NSMutableArray array];
    NSMutableArray *arr1 = [NSMutableArray arrayWithObjects:@"粤菜",@"西餐",@"川菜",@"日本料理",@"其他西餐",@"东南亚菜",@"湘菜",@"鄂菜",@"上海菜",@"香港美食",@"京菜",@"鲁菜",@"意大利菜",@"闽菜",@"韩国料理",@"西北菜",@"台湾美食",@"法国菜",@"苏菜",@"澳门美食", nil];
    NSMutableArray *arr2 = [NSMutableArray arrayWithObjects:@"海鲜",@"蔬菜",@"猪肉",@"牛肉",@"鸡肉",@"河鲜",@"羊肉",@"豆制品",@"乳制品",@"鸭肉",@"蛋制品", nil];
    NSMutableArray *arr3 = [NSMutableArray arrayWithObjects:@"甜",@"清淡",@"鲜",@"辣",@"椒盐",@"酸",@"五香",@"麻辣",@"孜然",@"咖喱", nil];
    self.arr = [NSMutableArray arrayWithObjects:arr1, arr2, arr3, nil];
    
    NSMutableArray *urlArr1 = [NSMutableArray arrayWithObjects:@"2229",@"2235",@"2255",@"2261",@"2267",@"2245",@"2239",@"2277",@"2253",@"2231",@"2295",@"2281",@"2263",@"2251",@"2287",@"2275",@"2241",@"2265",@"2247",@"2249", nil];
    NSMutableArray *urlArr2 = [NSMutableArray arrayWithObjects:@"22139",@"22131",@"22121",@"22125",@"22127",@"22137",@"22123",@"22143",@"22145",@"22129",@"22147", nil];
    NSMutableArray *urlArr3 = [NSMutableArray arrayWithObjects:@"22101",@"22113",@"22201",@"2237",@"2259",@"2299",@"22115",@"22107",@"22111",@"22103", nil];
    self.arr1 = [NSMutableArray arrayWithObjects:urlArr1, urlArr2, urlArr3, nil];
    
    scrollView.contentSize = CGSizeMake(self.view.frame.size.width, _tableView.frame.origin.y + self.view.frame.size.height / 3 * self.arr.count);
    
    
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 3;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    TheCuetomCell *cell = [tableView dequeueReusableCellWithIdentifier:@"guo"];
    cell.theImageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"food%ld.JPG", indexPath.row + 1]];
    cell.backgroundColor = [UIColor clearColor];
    return cell;
    
    
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return self.view.bounds.size.height / 3;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    CookStyleViewController *cook = [[CookStyleViewController alloc] init];
    cook.arr = [self.arr objectAtIndex:indexPath.row];
    cook.arr1 = [self.arr1 objectAtIndex:indexPath.row];
    cook.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:cook animated:YES];
    [cook release];
}

//- (void)scrollViewDidScroll:(UIScrollView *)scrollView
//{
//    CGFloat y = scrollView.contentOffset.y;
//    if (y < self.theImageView.frame.size.height) {
//        CGRect frame = self.theImageView.frame;
//        frame.size.height = -y;
//        frame.origin.y = y;
//        self.theImageView.frame = frame;
//    }
//}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
